﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using Objects;
using BAL;

public partial class Admin_UCControls_UCDuyet_ThongTinKhachHang : System.Web.UI.UserControl
{
    public static Duyet item;

    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            DanhSachChoDuyet itemChoDuyet = new DanhSachChoDuyet();
            itemChoDuyet = (DanhSachChoDuyet)Session["ItemDuyet"];

            item = new Duyet();

            if (itemChoDuyet != null)
            {
                item = BALDuyet.GetById(itemChoDuyet.Id);
            }

            if (item != null)
            {
                DangKy itemDangKy = new DangKy();
                itemDangKy = BALDangKy.GetById(item.IdDangKy);

                GetThongtinKhachHang(itemDangKy.IdKhachHang);
                GetThongtinKhachHangTrenThe(itemDangKy.IdKhachHangNhanThe);

            }
        }
    }

    public void GetThongtinKhachHang(int Id)
    {
        if (Id > 0)
        {
            KhachHang khachHang = new KhachHang();
            khachHang = BALKhachHang.GetById(Id);

            lblHoTen.Text = khachHang.Ten.ToString();
            lblNgaySinh.Text = khachHang.NgaySinh.ToString("dd/MM/yyyy");
            lblSoDienThoai.Text = khachHang.DienThoaiNha.ToString();
            lblCMND.Text = khachHang.CMND.ToString();
            lblDiachi.Text = khachHang.DiaChiLienLac.ToString();
            lblDiaChiThuongTru.Text = khachHang.DiaChiThuongTru.ToString();
            lbldtdd.Text = khachHang.DienThoaiDiDong.ToString();
            lblEmail.Text = khachHang.Email.ToString();
            if (khachHang.GioiTinh.ToString() == "2")
            {
                lblGioitinh.Text = "Nữ";
            }
            else
            {
                lblGioitinh.Text = "Nam";
            }
        }

    }

    public void GetThongtinKhachHangTrenThe(int Id)
    {
        if (Id > 0)
        {
            KhachHangNhanThe khachHang = new KhachHangNhanThe();
            khachHang = BALKhachHangNhanThe.GetById(Id);

            lblHotenTrenThe.Text = khachHang.Ten.ToString();
            lblNgaysinhTrenThe.Text = khachHang.NgaySinh.ToString("dd/MM/yyyy");
            lblEmailTrenThe.Text = khachHang.Email.ToString();
            lblCMNDTrenThe.Text = khachHang.CMND.ToString();
            lbldiaChiLLTrenThe.Text = khachHang.DiaChiLienLac.ToString();
            lblDCTTrenThe.Text = khachHang.DiaChiThuongTru.ToString();
            lblDTTrenThe.Text = khachHang.DienThoaiNha.ToString();
            lblDTDDrenThe.Text = khachHang.DienThoaiDiDong.ToString();
            if (khachHang.GioiTinh.ToString() == "2")
            {
                lblGioiTinhTrenThe.Text = "Nữ";
            }
            else
            {
                lblGioiTinhTrenThe.Text = "Nam";
            }

        }
    }
}
